import request from '@/utils/request'
import qs from 'qs'
import store from '@/store'

// 获取创建人、归属人、填写人???
// export const getUserPageList = () => {
//     return request({
//         url: `/blade-system/user/page?current=1&size=1000&deptId=${store.getters['userInfo'].deptId}`,
//         method: 'get'
//     })
// }
export const getUserPageList = () => {
    return request({
        url: `/crm-service/app/user?current=1&size=1000`,
        method: 'get'
    })
}

// 获取商机拜访列表
export const getBusinessVisitList = (data) => {
    const querydata = qs.stringify(data)
    return request({
        url: `/crm-service/app/businessVisit/list?${querydata}`,
        method: 'get'
    })
}

export const getBusinessVisiting = (id) => {
    return request({
        url: '/crm-service/app/businessVisit/detail',
        method: 'get',
        params: {
            id
        }
    })
}

// 获取商机列表
export const getBusinessList = (data) => {
    const querydata = qs.stringify(data)
    return request({
        url: `/crm-service/app/business/page?${querydata}`,
        method: 'get'
    })
}

// 报价信息
export const getBusinessQuotationList = (data) => {
    const querydata = qs.stringify(data)
    return request({
        url: `/crm-service/app/businessQuotation/page?${querydata}`,
        method: 'get'
    })
}

// 商机来源
export const getBusinessChannel = (data) => {
    const querydata = qs.stringify(data)
    return request({
        url: `/web-service/businessChannel/select?${querydata}`,
        method: 'get'
    })
}

// 商机详情
export const getBusinessDetail = (data) => {
    const querydata = qs.stringify(data)
    return request({
        url: `/crm-service/app/business/detail?${querydata}`,
        method: 'get'
    })
}

// 商机报价单详情
export const getBusinessQuoteDetail = (data) => {
    const querydata = qs.stringify(data)
    return request({
        url: `/crm-service/app/businessQuotation/detail?${querydata}`,
        method: 'get'
    })
}


// 获取商机跟进
export const getBusinessFollowUpList = (data) => {
    const querydata = qs.stringify(data)
    return request({
        url: `/crm-service/app/businessFollowUp/list?${querydata}`,
        method: 'get'
    })
}

/**
 * 查询商机关联线索
 * */
export const getRelevanceClue = (params) => {
    return request({
        url: '/crm-service/business/list',
        method: 'get',
        params: params
    })
}

/**
 * 新增商机拜访
 * */
export const addBusinessVisiting = (row) => {
    return request({
        url: '/crm-service/app/businessVisit/submit',
        method: 'post',
        data: row
    })
}


/**
 * 查询商机跟进详情
 * */
export const getBusinessFollowUp = (id) => {
    return request({
        url: '/crm-service/app/businessFollowUp/detail',
        method: 'get',
        params: {id}
    })
}

/**
 * 新增商机跟进
 * */
export const addBusinessFollowUp = (row) => {
    return request({
        url: '/crm-service/app/businessFollowUp/submit',
        method: 'post',
        data: row
    })
}

export const addBusiness = (row) => {
    return request({
        url: '/crm-service/app/business/submit',
        method: 'post',
        data: row
    })
}

export const getQuoteSubject = () => {
    return request({
        url: '/crm-service/quoteSubject/search',
        method: 'get',
    })
}

// 报价产品明细列表
export const getProductList = (params) => {
    return request({
        url: '/eb-service/product/list',
        method: 'get',
        params: params
    })
}

export const addBusinessQuotation = (row) => {
    return request({
        url: '/crm-service/app/businessQuotation/submit',
        method: 'post',
        data: row
    })
}

export const updateQuoteStatus = (row) => {
    return request({
        url: '/crm-service/app/businessQuotation/updateStatus',
        method: 'post',
        data: row
    })
}